﻿<template>
  <el-dialog v-el-drag-dialog class="dialog-mini" width="500px" title="新增/编辑" :visible.sync="visible">
    <el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="100px">
      <el-form-item size="small" label="密码" prop="passWord">
        <el-input v-model="temp.passWord"></el-input>
      </el-form-item>
      <el-form-item size="small" label="真实姓名" prop="realName">
        <el-input v-model="temp.realName"></el-input>
      </el-form-item>
      <el-form-item size="small" label="手机号" prop="phone">
        <el-input v-model="temp.phone"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button size="mini" @click="visible = false">取消</el-button>
      <el-button size="mini" type="primary" @click="saveData">确认</el-button>
    </div>
  </el-dialog>

</template>

<script>

import elDragDialog from '@/directive/el-dragDialog'
import * as apiAdmin from '@/api/user/adminUser'
export default {
  components: {},
  directives: {
    elDragDialog
  },
  data() {
    return {
      temp: {},
      dialogRoleVisible: false, // 分配角色对话框
      visible: false,
      rules: {
        name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
      },
    }
  },
  created() {
    this.getDetail();
  },
  methods: {
    //显示对话框
    show(record) {
      // 显示窗口
      this.visible = true;
      // 当前记录
      this.temp = record;
      // 更新form元素
      this.$nextTick(() => {
        this.$forceUpdate();
      });
    },
    getDetail() { // 获取详情
      // apiAdmin.getDetail({ id: this.temp.id }).then((res) => {
      //   this.temp = res.result;
      //   // 更新form元素
      //   this.$nextTick(() => {
      //     this.$forceUpdate();
      //   });
      // })
    },
    saveData() { // 更新提交
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          const tempData = Object.assign({}, this.temp)
          // apiAdmin.addOrUpdate(tempData).then(() => {
          //   // 显示成功
          //   this.$message.success(result.message, 1.5);
          //   // 关闭对话框事件
          //   this.handleCancel();
          //   // 通知父端组件提交完成了
          //   this.$emit("handleSubmit");
          // })
        }
      })
    },
    //  关闭对话框事件
    handleCancel() {
      this.visible = false;
      this.form.resetFields();
    },

  }
}
</script>
<style scoped>
</style>
